home *** CD-ROM | disk | FTP | other *** search
/ Asobe! Fotoshock 5.0 ERO / Asobe! Fotoshock 5.0 ERO.iso / pc / tool.dxr / 00029_slider.ls < prev    next >
Encoding:
Text File  |  1999-03-23  |  4.7 KB  |  172 lines

  1. property button, bar, direction, min, max, percentage, range, offset, location, name, downmem, msgMovie, msgSprite, msgSpriteNum, sliderMsg, defaultVal
  2. global gpartslist, grgbspnum, grgblist, gmyphotonum
  3.  
  4. on getPropertyDescriptionList
  5.   set s to the currentSpriteNum
  6.   if s > 0 then
  7.     set nameDef to the name of member the member of sprite s
  8.     set memDef to nameDef & "*"
  9.     set barDef to s - 1
  10.   end if
  11.   set plist to [:]
  12.   addProp(plist, #name, [#comment: "Slider Name:", #format: #string, #default: nameDef])
  13.   addProp(plist, #bar, [#comment: "Range channel:", #format: #integer, #default: barDef])
  14.   addProp(plist, #direction, [#comment: "Direction:", #format: #symbol, #default: #horizontal, #range: [#horizontal, #vertical]])
  15.   addProp(plist, #defaultVal, [#comment: "Default Value (%):", #format: #integer, #default: 1])
  16.   addProp(plist, #msgMovie, [#comment: "Message Movie:", #format: #boolean, #default: 1])
  17.   addProp(plist, #msgSprite, [#comment: "Message Sprite:", #format: #boolean, #default: 0])
  18.   addProp(plist, #msgSpriteNum, [#comment: "Sprite Number:", #format: #integer, #default: 1])
  19.   addProp(plist, #sliderMsg, [#comment: "Send this message:", #format: #string, #default: "sliderIsMoving"])
  20.   return plist
  21. end
  22.  
  23. on getBehaviorDescription
  24.   return "Creates a slider"
  25. end
  26.  
  27. on beginSprite me
  28.   set sliderMsg to value("#" & sliderMsg)
  29.   set button to the spriteNum of me
  30.   setDirection(me)
  31.   set offset to 0
  32.   if defaultVal < 1 then
  33.     set defaultVal to 1
  34.   end if
  35.   if defaultVal > 100 then
  36.     set defaultVal to 100
  37.   end if
  38.   if voidp(grgblist) then
  39.     set grgblist to [#redShift: 255, #greenShift: 255, #blueShift: 255]
  40.     sort(grgblist)
  41.   end if
  42.   case name of
  43.     "Red":
  44.       set v to getaProp(grgblist, #redShift)
  45.     "Grn":
  46.       set v to getaProp(grgblist, #greenShift)
  47.     "Blu":
  48.       set v to getaProp(grgblist, #blueShift)
  49.   end case
  50.   set val to 100 * (v + 255) / 510
  51.   set the text of field member (name & "Value") to string(val)
  52.   setSlider(me, val)
  53.   return me
  54. end
  55.  
  56. on setBar me, b
  57.   set bar to b
  58.   setDirection(me)
  59. end
  60.  
  61. on setLocation me, l
  62.   case direction of
  63.     #horizontal:
  64.       set the locV of sprite button to l
  65.     #vertical:
  66.       set the locH of sprite button to l
  67.   end case
  68.   setSlider(me, percentage)
  69. end
  70.  
  71. on mouseDown me
  72.   operate(me)
  73. end
  74.  
  75. on operate me
  76.   repeat while the mouseDown
  77.     if direction = #horizontal then
  78.       set mh to the mouseH
  79.       if mh < min then
  80.         set mh to min
  81.       end if
  82.       if mh > max then
  83.         set mh to max
  84.       end if
  85.       set the locH of sprite button to mh
  86.       set offset to mh - min
  87.     else
  88.       set mv to the mouseV
  89.       if mv > min then
  90.         set mv to min
  91.       end if
  92.       if mv < max then
  93.         set mv to max
  94.       end if
  95.       set the locV of sprite button to mv
  96.       set offset to min - mv
  97.     end if
  98.     set percentage to offset * 100 / range
  99.     set the text of field (name & "Value") to string(percentage)
  100.     tell getAt(the windowList, 1)
  101.       if value(grgbspnum) <> 0 then
  102.         set xxx to value("#" & string(grgbspnum))
  103.         setalpha(getProp(gpartslist, xxx), name, percentage)
  104.       end if
  105.     end tell
  106.     updateStage()
  107.   end repeat
  108. end
  109.  
  110. on setSlider me, P, Flag
  111.   set percentage to P
  112.   set offset to range * percentage / 100
  113.   case direction of
  114.     #horizontal:
  115.       set the locH of sprite button to offset + min
  116.     #vertical:
  117.       set the locV of sprite button to min - offset
  118.   end case
  119.   if voidp(Flag) then
  120.     tell getAt(the windowList, 1)
  121.       if value(grgbspnum) <> 0 then
  122.         set xxx to value("#" & string(grgbspnum))
  123.         setalpha(getProp(gpartslist, xxx), name, percentage)
  124.       end if
  125.     end tell
  126.   end if
  127.   updateStage()
  128. end
  129.  
  130. on setDirection me, d
  131.   if not voidp(d) then
  132.     set direction to d
  133.   end if
  134.   case direction of
  135.     #horizontal:
  136.       set min to the left of sprite bar
  137.       set max to the right of sprite bar
  138.       set range to max - min
  139.     #vertical:
  140.       set min to the bottom of sprite bar
  141.       set max to the top of sprite bar
  142.       set range to min - max
  143.   end case
  144. end
  145.  
  146. on reflectrealvalue me
  147.   case gmyphotonum of
  148.     2, 28:
  149.       exit
  150.     otherwise:
  151.       if voidp(grgblist) then
  152.         set grgblist to [#redShift: 255, #greenShift: 255, #blueShift: 255]
  153.         sort(grgblist)
  154.       end if
  155.       tell getAt(the windowList, 1)
  156.         set rgbmem to the member of sprite grgbspnum
  157.         set nowrgb to geteffectargs(rgbmem, #rgb)
  158.       end tell
  159.       case name of
  160.         "Red":
  161.           set v to getaProp(nowrgb, #redShift)
  162.         "Grn":
  163.           set v to getaProp(nowrgb, #greenShift)
  164.         "Blu":
  165.           set v to getaProp(nowrgb, #blueShift)
  166.       end case
  167.       set val to 100 * (v + 255) / 510
  168.       set the text of field member (name & "Value") to string(val)
  169.       setSlider(me, val)
  170.   end case
  171. end
  172.